<template>
    <a-result title="必须输入想要创建的项目项目类型" v-if="noType">
    </a-result>
    <a-result title="现在无法申报大创项目" v-if="!canApp">
        <p>
            <strong>申报大创项目必须同时满足以下条件：</strong>
        </p>
        <p v-for="(v, k) in errorStrings" :key="k">
            <CheckCircleFilled v-if="v"  class="color-success" />
            <close-circle-outlined v-else class="color-error" />
            <span class="ml5">
                {{ k }}
            </span>
        </p>
    </a-result>
    <a-result title="正在创建项目中" v-else></a-result>
</template>
<script setup>
import app from '@/app'
import { ref, reactive, watch, onMounted } from 'vue'
import axios from '@/axios'

const noType = ref(false);
const canApp = ref(true);
const errorStrings = ref([]);
async function load () {
    const type = app.queryString("type");
    if (!type) {
        noType.value = true;
        return;
    }
    let msg = await axios.post("/api/proj/common/CreateInnovProject", { type });
    canApp.value = msg.success;
    errorStrings.value = msg.errorStrings;

    if (canApp.value) {
        const id = msg.data.basicInfo.ID;
        app.toPage({
            path: "/manage/proj/editor",
            query: {
                id
            }
        });
    }
}

onMounted(load);
</script>